package ctl;

import java.util.Date;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import my.dao.MyDao;

@RestController
public class MyController {

	@RequestMapping("/ins-data")
	public String insertData(Integer n) {
		MyDao.update("delete from student");
		if(n==null || n<10) n = 10;
		int cnt = (int)(Math.random()*(n+100));
		
		for(int i=1;i<=cnt;i++) {
			MyDao.update("insert into student values(?,?,?,?)",i,"学生"+i,new Date(),30+Math.random()*70);
		}
		System.out.println(MyDao.queryInteger("select count(*) from student"));
		return MyDao.queryJsonArray("select * from student");
		
	}
	
	@RequestMapping("/test1")
	public String test1(int cnt) {
		return MyDao.queryJsonArray("{call proc_init_stu(?)}", cnt);
	}
	
}
